package com.cdxy.dmr.repository;

import com.cdxy.dmr.dataObject.SceneTicketDO;
import com.cdxy.dmr.mapper.SceneTicketMapper;
import com.cdxy.model.dto.base.mybatis.BaseRepository;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: tangy
 * @Date: 2020/4/6 15:45
 */
@Repository
@CacheConfig(cacheNames = "scene_ticket")
public class SceneTicketRepository extends BaseRepository<SceneTicketMapper, SceneTicketDO> {
    /**
     * 通过景点id查询
     *
     * @param sceneId
     * @return
     */
    @Cacheable(key = "#sceneId", unless = "#result == null ")
    public List<SceneTicketDO> listBySceneId(Integer sceneId) {
        return this.baseMapper.selectList(this.queryWrapper().eq(SceneTicketDO::getSceneId, sceneId));
    }
}
